package me.idashu.attg.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import me.idashu.attg.domain.AdverEntity;
import me.idashu.attg.domain.PageEntity;
import me.idashu.attg.persistence.AdverMapper;
@Service
public class AdverService {
    @Autowired
	private AdverMapper adverMapper;
    
    public List<AdverEntity> getAllAdver(Map<String, Object> map){
    	List<AdverEntity> listAdver = adverMapper.getAllAdver(map);
    	return listAdver;
    }
    
    public List<AdverEntity> getAllAdvers(){
    	List<AdverEntity> listAdver = adverMapper.getAllAdvers();
    	return listAdver;
    }
    
    public List<AdverEntity> getLaunchImg(){
    	List<AdverEntity> listAdver = adverMapper.getLaunchImg();
    	return listAdver;
    }
    
    public void insertAd(AdverEntity adver){
    	int goodid = adverMapper.getIdByGoodsName(adver.getGoods_Name());
    	System.out.println("goodid:"+goodid);
    	adver.setGoods_Id(goodid);
    	System.out.println("goodid2:"+adver.getGoods_Id());
    	adverMapper.insertAdver(adver);
    }
    
    public int countAd(){
    	return adverMapper.countAdver();
    }
    
    public void deleteAd(int id){
    	
    	adverMapper.deleteAd(id);
    }
}
